import _Reflect$has from 'babel-runtime/core-js/reflect/has';
import _extends from 'babel-runtime/helpers/extends';
import { combineReducers } from 'redux';
import { routerReducer as router } from 'react-router-redux';

import system from './modules/system';

function createReducer(asyncReducers) {
  return combineReducers(_extends({}, asyncReducers, {
    system: system,
    router: router
  }));
}

function injectReducer(store, _ref) {
  var key = _ref.key,
      reducer = _ref.reducer;

  if (_Reflect$has(store.asyncReducers, key)) return;

  store.asyncReducers[key] = reducer; // eslint-disable-line no-param-reassign
  store.replaceReducer(createReducer(store.asyncReducers));
}

export { createReducer, injectReducer };